package com.qf.flash.ui.circle.adapter;

import android.view.View;
import android.widget.ImageView;

import com.qf.flash.R;
import com.qf.flash.model.VideoListBean;
import com.qf.flash.ui.circle.VideoPlayerActivity;
import com.qf.flash.utils.ImageLoader;
import com.qf.flashlib.adapter.BaseRViewItem;
import com.qf.flashlib.adapter.RViewHolder;


public class VideoItem extends BaseRViewItem<Object> {

    @Override
    public boolean isItemView(Object entity, int position) {
        return entity instanceof VideoListBean;
    }

    @Override
    public int getItemLayout() {
        return R.layout.item_video;
    }

    @Override
    public void convert(RViewHolder holder, Object entity, int position, int itemSize) {
        VideoListBean videoListBean = (VideoListBean) entity;
        ImageView iv = holder.getView(R.id.iv);
        ImageLoader.load(holder.getmConvertView().getContext(), videoListBean.getImage(), iv);
        holder.setText(R.id.tv_time,videoListBean.getShowTime());

        holder.getmConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                VideoPlayerActivity.start(holder.getmConvertView().getContext(),videoListBean.getTitle(),videoListBean.getVideoUrl());
            }
        });
    }
}
